FROM debian:bookworm

# 1. 配置 Debian 官方源（中科大镜像）和树莓派源
RUN echo "deb http://mirrors.ustc.edu.cn/debian bookworm main contrib non-free" > /etc/apt/sources.list && \
    echo "deb http://mirrors.ustc.edu.cn/debian bookworm-updates main contrib non-free" >> /etc/apt/sources.list && \
    echo "deb http://mirrors.ustc.edu.cn/debian-security bookworm-security main contrib non-free" >> /etc/apt/sources.list && \
    # 树莓派源暂时注释，避免 update 时校验失败
    echo "# deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ bookworm main" > /etc/apt/sources.list.d/raspi.list

# 2. 仅更新 Debian 源，安装 gnupg（此时树莓派源被注释，不会校验）
RUN apt-get update --allow-unauthenticated && \
    apt-get install -y --no-install-recommends --allow-unauthenticated gnupg ca-certificates && \
    rm -rf /var/lib/apt/lists/*

# 3. 启用树莓派源，导入密钥
RUN sed -i 's/^# deb/deb/' /etc/apt/sources.list.d/raspi.list && \
    apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 9165938D90FDDD2E

# 4. 更新所有源并安装依赖 包procps/top指令 包iputils-ping/ping指令 
RUN apt-get update && \
    apt-get install -y --no-install-recommends vim \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /root

# 构建镜像
# docker build --platform=linux/arm64 -t rasp_pro_image .
# 创建容器
# docker run -it -v d:\work:/root/work --platform linux/arm64 --name rasp_pro_container --restart always rasp_pro_image bash
# 再次进入
# docker exec -it rasp_pro_container bash
# 镜像保存 
# docker save -o /path/to/rasp_pro_container.tar rasp_pro_container:latest
# 镜像加载
# docker load -i /path/to/rasp_pro_container.tar
# 容器守护
# docker update --restart=always rasp_pro_container

